﻿using Grow.Binary.CreateBinary;
using Grow.Binary.MessagePack.CreateBinary;
using Grow.Module;
using Grow.Module.Service;
using Microsoft.Extensions.DependencyInjection;

namespace Grow.Binary.MessagePack
{
    public abstract class BinaryMessagePackModuleBase : ModuleBase, IBinaryModule
    {
        public override ModuleLevel Level => ModuleLevel.Framework;
        public override void AddDependModule(IDependModuleBuilder dependModuleBuilder)
        {
        }


        public override void AddService(IServiceContainer serviceContainer)
        {
            CreateBinaryBuilder createBinaryBuilder = new();
            CreateBinary(createBinaryBuilder);
            serviceContainer.BuilderManager.SetBuilder<ICreateBinaryBuilder>(createBinaryBuilder);


            _ = serviceContainer.ServiceCollection.AddTransient<IBinaryContext, BinaryContext>();
        }

        public abstract void CreateBinary(ICreateBinaryBuilder createBinaryBuilder);

        public override void UseService(IServiceContext serviceContext)
        {
        }
    }
}
